little rework of detect_trips