Created two functions for assignment2