Bug in plotting function corrected