position the cursor to the correct position