Simply just keep popping the queue until it's empty. No point in using a for loop for this. Combined some if statements too.