Implemented code for assignment 2