fixed crash on error.