added bdd code and old algorithm