added catching of exceptions