changed to use google's sample code