refactor and js doc