fix history sorting