Improved hash algortithm