deal with non-monotonic timestamps