Add condition to queue code to not move entries to history when the list is empty