wrote test cases for method 2