Move some business logic to model.