add segment option to function.