modified minmax code, store the values in array( i think..)