Merging sorted arrays problem