Refactor ordering machine