Fix leaking then variable