fixing markup and cursor movement