Improve variable capture