use std min and max