updates to code for manuscript.