add: function for two-step optimization