make sure segments is an array before merging