refactoring and some enhancement to the order feature