this is hopefully working segment generation