Updated to use temp dir