The block-localized wavefunction method and its application