Move logic to model and simplify.