refactoring + better goroutine support