add comments
added some test and fixes