fix goroutine problems