added comments and unit test