Modified to handle negation of complex rules