The bit-error rate (BER) of a storage or transmission channel may be data-dependent. This can lead to certain pathological input sequences, for which the reliability of the system is below specifications. Guided scrambling is a well-known technique to randomize the input to a channel while minimizing a certain objective function. In this paper, we take the average predicted BER as the objective function. We show that for a certain scrambling code C, for any input sequence m there exists a scrambling codeword c∈C such that the predicted BER of the (modulo-2) sum of m and c is not more than that for random input data. We present examples of scrambling codes for two-dimensional optical storage and indicate a way of combining them with error-correcting codes.