2.7 updated with while loop, tolerance level