check if origin->segments is NULL, Avoid crashes