namespace the js code

make it more modular to help debug