added comments. found possible bug