fixed index OOB bug