bug with max value fixed