Fixed bug + added temp dir in SCRATCH dir