history pagination logic fixes