added a new trim option and moved to a least squares model for fitting