Changes javascript vars to local scope