Properly scoping the tmp array