Trying to use waitgroup but getting deadlocks