changed from using /tmp to using a mktemp