plotting functions updated and a main function