sg refactoring