Adjusting code sample to the new api 

I've tried to use and discovered that the api is changed.
Just adjusting the sample.
Merge remote-tracking branch 'origin/patch-1'