fix problem with unsafe comparisons