Edited functions for Assignment 2