improved pagination process