Fixed errors in my simple fitting code