Code for DB3 paper