Update the example code with comments and the new callbacks