Refactored code without delays