refactor cursor