added documentation to javascript