Added exception handling in the processing thread