update javscript to improve effeciency