implements safety techniques for event listeners