Fix bug out of range