code adapted to new casadi syntax