refactors code. forEachHex is glorious