refactor clean up JS