core dump fix cuz global was not reset