Integrated the loa code with the new algorithm