upating JS logic