Changed to preserve cursor position