proper max value detection.