Adding the second function and test cases for Part B