fix db function