add xor operation before bit counting.