Replace has_variable with direct checks of variable existence