Refactoring of index action in controller
Minor refactoring