refactor generator