1st working version with temp folder