margin order refactoring