better optimisation and image plotting