refactoring background code