Works except for outofboundsexception when hitting left and right side.