Improve combine-both function
Fix mistakes in combine function