fixed index error bug