modified the function and application.rb