corrected minimization and maximzation issue