Using max and min filter