Rework JS code to adhere to John Papa's style guide