Replace loop with eventlistener for location updates