improved speed and added legends to the plots