Please show your complete code. We e.g. don't know what the threshols are.
You refer to threshold but there are three thresholds in your code so please explain what you exactly want to achieve.
Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project
See About the Installation & Troubleshooting category.