Extract some logic to model.