adapting the js to requirejs