fixed Cursor position calculation