Changed Max Function