Use max/min functions to avoid conditions