Should this be moved before the inner loop?