Fixed possible OutOfBounds exception