fixed moveable platform code to switch directions even when it cannot fully get to the end or start