Simplify try/except block