improve generated code for try catch blocks