rewrote findVariance to a more readable form