Refactor index template