fixing the global destruction error that has been a problem for a while