refactored bg