refactor models generator