adding feature for correct counting of paginated results (according to stack overflow, not truly tested)