Fixed. DA to a reasonable algorithm

Fixed. DA to a reasonable algorithm