seems factoring out hash calculations worked