A new simultaneous autofocus and twofold astigmatism correction method is proposed for High Angle Annular Dark Field Scanning Transmission Electron Microscopy (HAADF-STEM). The method makes use of a modification of image variance, which has already been used before as an image quality measure for different types of microscopy, but its use is often justified on heuristic grounds. In this paper we show numerically that the variance reaches its maximum at Scherzer defocus and zero astigmatism. In order to find this maximum a simultaneous optimization of three parameters (focus, x- and y-stigmators) is necessary. This is implemented and tested on a FEI Tecnai F20. It successfully finds the optimal defocus and astigmatism with time and accuracy, compared to a human operator.