improved example code