improvements for the clustering function and tweaks to make the timeline work smoothly