added wait_case_matrix function to wait for cluster cases to finish