getting assignments to sort via distance properly, add cleaning to update and insert