modified for parameter fitting