bug fix, added comments