Refactor rake task.