Added grid to move_cursor function