fixed a printing bug, and made a stats function for printout index