Fixed bug in the set db function