solution for book exercises