moved error messages generation to model