add update functionality, ensure canonical ordering