added test cases & removed unreachable code