added definiton of merge function