Updated functions for Assignment 2