Refactor how total hits are calculated