Functioning goodness of fit code