Hm... there is some limitations in example code, concerning local variables in nested functions... here is workaround http://pastebin.com/mQaKXaYY