Refactored variance method