removed duplication in exception catching