improve waitForEmptyQueue
Formatting