UPDATE: Refactored code
UPDATE: Refactored code