order sync algorithm