Removing duplicate code from merge