bug fix and closure