Refactoring to add concurency