Need to fix issue with indexOutOfBounds exceptions