added convenience fitting function code
(#325)