Combined two similar ifs to one with xor