simplified the logic opearation with an xor