move the js to a js file where it belongs.
remove useless intermediate variable