solve exercises 4.18 - 4.21