fixed disastrous O(n) performance from merge which should be O(1)