Fixing JS functions