Fix a bug of max size calculation