use closure to avoid variation overwrite