removing duplicated code from merge