Corrected BHLDA code