Tried to fix sigsegv with error checking, no dice