Updated algorithm to dynamically change epsilon and lambda values