factored out the js