added comments, added implementation