update code snippet to use the new API