Extracted parity code to the Parity class.