put val in a block scope to avoid an objc error