Extracted prepareEvent method