Function captureEvents