minor restructure of example code