updated js code example