implementation of printIndex()