added code for fig 1