Restructure the code to be like the books code