LD Algorithm fix bug