Added function to free the queue