solve exercises 5.17 - 5.23