rewrite to describe r code rather than the javascript