fix history ordering bug