code based on book