Resrtuctirng and beautification of the index file