Modified the code and unit test cases