basic version ,with XOR