book example code working