minor code changed and test cases