move out order logic to Order model and refactor code