better fix for SIGSEGV