almost done with merge subroutine