Replace modulo by AND gatter