Fixed bug in cursor movement