Refactor populate task code for production/heroku