fixed some problems with cursor postion