wrap the mean and covMatrix finding code into func