New solution

First attempt to solve Min and Max
Works, but lot of room for improvement