This logic is wrong. Who says max is an integer?