move event segmentation to db