refactored code into rake tasks