Completed sdb code