Refactored to remove logic from app.rb