Refactored code into Utils