Simply loop by checking for < tolerance in while rather than inside loop