Use min() instead of if and else comparison