Fix boolean logic bugs/confusions
clarify boolean logic