added scaling to fitting