changed location of validation of database errors