Merge duplicated code