refactoring with catch