changed mod to ** and implemented binary XOR