changed catching of exceptions