Made it more readable for threshhold
Removed duplicate code