Added discrepancy function