added code from nersc and mean ginding code