reorganize the result output dir logic.