Fix: segment's length are now calculated correctly