updated js code