Fix threshold argument passing to function
Fix creation temp file
Fix default threshold value