dicvide and conquer method