refactoring irgen