some changes, added comments;