Fixed min/max

The min/max functions didn't work correctly for lists longer than 3 elements.