changed exception catching according to Coryt
's comments