added5% tolerance limit to thresh color, fixed some indents