added set to undefined before delete to facilitate better garbage collection (could be wrong about this let me know)