Fix the problem occured when specifying directories