Added fitting function