created two functions for assignment2