implemented merge sorted arrays algorithm