Why not wrap the entire thing in a closure?