Updated segment code