Added if for max