Solution for plot 2