Refactor and comment for readability
JSHint adherence