split out ordering and update related into managable subfunctions