fix bug with reference closing that I swore we fixed