Fix OutOfBoundException check.