change donut, pie algorithm