bug fixing and unit test case implemented