better handling of db error