My solution to the assignment