Fix bug related to variable capture