move code for fetching data from google api into object