fix: avoid memory leaks using event listeners