Fixed exception catching