Return total number of results; refactor client