replace try with explicit checking to avoid database error: transaction aborted