Replaced equality checks with tolerance checks