private boolean isValidDirectory(File dir) {
        if (!dir.exists()) {
            System.err.println("Directory doesn't exist: " + dir.getAbsolutePath());
            return false;
        } else if (!dir.isDirectory()) {
            System.err.println(dir.getAbsolutePath() + " is not a directory");
            return false;
        }
        return true;
    }