Refactoring for key generators