bug fixed; added comments