Standard deviation refactoring