Fix variable scope in addNote callback