Fix exception not working properly