refactored to use models