Perfomance fix

If server result count more than total (_search function) - _search function call additional unnecessary call to API.
I refactored code for avoid this