refactoring handler for index page