running into issues with xor/loop