divide and conquer implemented