split up the js code