correction from Paul
order generation algo