Working solution but still crashing the machine