fix a bug in printIndex()