Why not just use a min/max function?