corrected algorithm of negative hash code handling