added comments and test cases