modify pagination function