code from stanford paper