wrote function to draw events