https://devhubby.com/thread/how-to-get-the-minimum-and-maximum-value-of-each