replace min with max, silly bugger