refactoring + generator working