some tweaks in flipping bits, should work now!