add code from textbook