move eventsource handling to its own module