try-catch refactor