fix db handling