Refactored JavaScript code to improve understanding of the code