global error variable solved to fix crash errors