Fixing location update javascript