updated js function