restructure bdd and code