Refactored code to be easier to remember