Added check for valid internal state