corrected index error