Refactored index.rb