Refactor rake task