Make segment_history more pythonic