added threshold to script