paginate function. pageindex is in fact not a index...