Fix bug with exception