fixed the example code which was using old api