Improve the logic slightly when merging two sorted lists.