added history pagination (bad but working)