BUG: added missing initialization of the model for cost function