Putting offset before count condition

Putting offset operation before count condition help fix problems with zero count of items, then offset is bigger then count of items.