fixed bug in pagging macro