fix bug in db handle code