could there be a bug here? since you are comparing an index to a count (zero based vs 1 based) ?