corrected smallhash function