heroku-friendly refactor