minor refactoring of gmaps function