Updated functions as required by Prog. Assignment 2