added ability to use pagination