@SuppressWarnings("SleepWhileInLoop")
    private boolean deleteAndWait(GitHubClient gitHubClient, Repository repository) throws IOException {
        Properties properties = ApplicationProperties.getProperties();
        RepositoryService repositoryService = new RepositoryService(gitHubClient);
        gitHubClient.delete("/repos/" + properties.getProperty(PropertiesConstants.GITHUB_ANON_USERNAME) + "/" + repository.getName());
        
        int maxAttempts = 5;
        for (int i = 0; i < maxAttempts; i++) {
            try {
                logger.log(Level.INFO, "Waiting for fork of {0} to delete...", repository.getName());
                Thread.sleep(5 * 1000);
                
                List<SearchRepository> searchRepositories = repositoryService.searchRepositories(
                        repository.getName()
                        + " user:" + properties.getProperty(PropertiesConstants.GITHUB_ANON_USERNAME) 
                        + " fork:only");
                
                if (searchRepositories.isEmpty()) {
                    return true;
                }
            }
            catch (InterruptedException | IOException e) {
                logger.log(Level.INFO, "Error waiting for fork of {0} to delete: {1}", new String[] {repository.getName(), e.getMessage()});
            }
        }
        
        logger.log(Level.INFO, "Deleting repository {0} took too long.", repository.getName());
        throw new IOException("Repository fork could not be deleted.");
    }