refactored with models