fixed the while loop for the right arrow key