changed scope of tmp-variable