changed File.exist to File.directory