improved error detection. Added error display.