Added catching of exceptions