Change last message detection from time to id