js build function improved