Move logic to model.