I've found an other way to do it, and it simplify my next iteration of the work. I've just put simple cases into the sprite and the sprite that has to move just go onto the cases, so it can't move out of it.
But in the first place I was moving it by adding X pos + sprite size to the new X pos till it is overlapping. But the way I need to use it, it wasn't appropriate in the first place.