added failsafe in db moduke