resource generator code refactoring