Are we not shadowing the 'val' from the outer scope? Is that what you want here?