add flush at the end of goroutines otherwise it does not work