Refactored code for readibility