This article discusses the problem of cleaning rough measurements (outliers) from a time series of noisy data received from measuring devices. Solving this problem is required to improve the accuracy of modern measuring equipment with the latest mathematical software. To minimize the amount of rejected data, the author of this article has previously formulated a problem of searching for the optimal solution and proposed a robust algorithm to solve it. The resulting solution approximates the optimal solution and does not always provide the desired minimization. An improved method of cleaning outliers from data is proposed, based on the search for the optimal solution with a minimum number of rejected measurement data. To implement this method, a problem is set that considers an unknown average of the original number series as a parameter to be determined. Additionally, an algorithm is proposed that enables us to assuredly find the optimal solution in no more than N steps, each of which requires an order of N arithmetic operations, where N is the number of initial measurement data. This improved method can be used to automatically detect and eliminate outliers from a time series of measuring data during their preliminary processing in information and measuring systems as well as in solving scientific, applied, managerial and other problems in various fields of human activity.