refactor and introduce model dactory