refactor generation to a new class