Handling logical expressions