Final Assignment 2 solution