Fix DB code

fixed DB code, tested against DB. Works for me.