Added a check to ensure we didn't go out of bounds of an array