finifshed initila version of qc checkning function