Updated code for generating figures