implemented avg and parity functions