Factored out logic to join two items