fix bug in divide and conquer