Made the hasing function more efficient.