Both D&C algorithms now working