added check if Path is directory