improved hash algorithm