Fixes a problem with variable capture through scoping