Changed to handle arbitrary number of workers