significant improvements to app.rb