now finding the local minima; added explainations