refator js version to make it more like cljs version