Refactoring - removed the lines of loop in the index template