Refactoring genconfig