overdue update
misc edits to make function more general
new code file for ms figures