In this work we tackle the problem of mitigating the multi-user interference by optimizing the time-hopping codes, in an asynchronous impulse radio multiple access scheme. We derive the expression of the multi-user interference variance at the output of a Rake receiver assuming that the codes are deterministic, for both pulse position modulation and pulse amplitude modulation formats, when propagating through multipath channels. The result shows that the code contribution is independent of the other parameters. We derive from this expression a practical criterion that enables us to find a set of optimal codes that ensures minimal multi-user interference variance at the receiver output. We check through simulations, that the set of optimal codes found using the criterion, leads to bit error rate improvement