rewritten to depend more heavily on goroutines