works for arbitrary num procs