add error detection.