Implemented functions for Home Assignment 2