reorganized some example code