refactored order memory mgmt into order