Refactored index to cut out repetitive code.