Refactor getData and add getPagination