refactored IF for index.html.erb