added code from google sample
added url parsing