fix a bug in boolean logic