Completed functions for Assignement 2