Made code a bit more generic to support Google-based APIs