refactored goroutine