Changed check for zero length queue