sample code from my PhD works