numerical error in optimization fixed