Added threshold and fixed bug in dictionary loading