Refactoring. Close cursor after using.