Major fix in complex algorithm