New fitting function that takes Nan