This has a built in function for undoing a window and moving it back to the original location.
In your macro you are setting the OriginalPosition regardless everytime so when you move the front window you are telling it to make OriginalPosition to where you current location is so