updated js

Updated js for best functionality