add check if transaction has errors before saving