code written for my nsf fellowship