fixed the comparisons as well as threading it.