Modified code for plotting tuning curves