refactoring bgext