repasted code from google CSE