Improved RAM usage and efficiency of eventlistner

Improved RAM usage and efficiency of eventlistner