fix bug in function moveRight