implemented automatic search for max intensity