Refactored some of the background task