rework of detect_trips