code from book examples