Added JSDoc comments
Minor refactor for clarity