My solution to ex5