Refactoring to tasks to queries