error handling for logical operation