Modularizing trainBdd