This logic should be simplified to make the code more readable.
Either extract two auxiliary methods from the OR clauses, or refactor the external NOT to the interior of the condition