fixed bug where db is not redefined after update