updated js file with better syntax