implementing bg
refactoring
refactoring
refactor done