var count is assigned in the inner loop so it must be checked inside there to be properly used as part of the exit condition of the outer loop
Put inner loop into own method, let's see whether it makes scrutinizer happier