Updated code sample to not use deprecated api