refactor and jsdoc comments