solution to Assignment 2