added segment detection