fix minor bug on loop - incr the indx!