moved event emitter like code to seperate file