fix main index function