global refactoring code