Added error detection.