fix crash on error