Trying to fix the seg faults