Updated to fit scale factor and phase shift simultaneously