Refactors index method.