Added validation for target directory