updated code for a cleaned up Figure 3, sent to journal