Yes. I think the error is likely in the section above, because the loop should only give you values between -1 and 5 (inclusive), but yours has somehow yielded a 6. You will probably have to post the whole function in-order for people to see where the problem is.