split segments into separate file; updated event handler