adding ability to change threshold on the fly.