worked on the min max funktion