fix error when dir is invalid value