fixed bugs
added comments