working code, still seg faults on old projects