update left right movement function