fix db undefined error