remove try-catch duplication