update variable references and add not_if guards