Added exception detection