This implements the functions required for assignment 2