Refactor app.rb into methods