some functions for minimizing a function added. there is still some work required but successfully applied in an aplication