Solution to assignment 2

This change includes the changed function for assignment 2.