fixing movement bug when switching between opposites directions