Working version of model estimation