A new simultaneous autofocus and two-fold 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 an image variance, which has already been used before as an image quality measure for different types of microscopy. In this paper we describe numerical simulations based on a classical HAADF-STEM linear image formation model showing that the modified variance reaches it's maximum for Scherzer focus and zero astigmatism. In order to find this maximum in a three-parameter space we employ the well-known Nelder-Mead simplex optimization algorithm. The method is implemented and tested on a FEI Tecnai F20.It successfully finds the optimal defocus and zero astigmatism with the time and accuracy, compared with the human operator. The method is iterative, and finding the optimal defocus and zero astigmatism requires obtaining typically 20-50 images.