bug fix and comments added