fixed print error, updated index