Moving objects problem

I want to move objects through a path and, when the path is finish, to start from the begging. All objects must have the same distance between them. Something like this:


The things is that, when the object reaches a certain point in the window (the end of the path) I change the position to the starting position. That causes that overlaps the last object in the path:


What can I do to solve this? I though of waiting X time for the object to change the y coordinate, but it will take different times on different computers.

Instead of changing the last object position to the starting position, you can set the position = first object position - distance. In this case,

red position = green position - distance.

You can use a variable to keep track the first object. When an object pass though the baseline, set the object position and set it as first object.