add a check for db connection to handle the db going away and coming back