kind of working. OutOfBounds exception at a random point