Added code for Fig 3