Fix boolean logic error