fixing function closure in capture