Improved optimal threshold estimation