Improving logical boolean comparison