Using old code from uberapi to consolidate to one function