refactored index controller method