Refactored javascript to work with new geolocation