Fix nested loop in import