changed merge function parameters from array to vector