refactored for model logic