fixed bug, added comments.