Code is copied from https://github.com/fuxiao0719/GeoWizard. Modifications are indicated within the code.