Refactor app.rb file