solving exercises for section 6.5