fixed output and plot bugs