LPS-47855 fix and cleanup Js code