Added a dynamic binary threshold optimization