moved part of logic to model