refactored code structure for google api