add directory check.