fixing OOB bug