Fix bug in updating order