code style. Could you define the i variable locally in the loops rather than having the one in the front. That is a bit weird to read