Refactored code pursuant to airbnb js style guide