refactored model with tests