Solving homework 4