updated index creation to be run as a library method.