refactor bg