copying of merge function replaced with retype