correct and improve inverse_opt solver