wrote 2 functions for assignment 2