fix implementation of parity