fix the bug of juding if directory exists or not