Added code from BDT repository