Refactoring and supporting different generation strategy