new fit_workspace function and improved minimize