added comments, added assertions