move global js functions to namespace