fixed catching of exceptions