the functions for assignment 2