found whats causing the seg fault. Can't figure out how to fix it