refactored code and added bdfs and bbfs