fixed bugs added comments