Implemented solution for Assignment 2