minor speedup using XOR intead of popcount