added temp file and folder delete to flush method