modified function when() trying to fix the problem when users cannot be geolocalized