crash fix and better error message