added codes for plotting