Prevent possible IndexOutOfBoundsException.