Completed functions for Assignment 2