created function for assignment 2