memory leaks, and del function isn't correct