merging working sans recursion