diff --git a/matlab/IMAS/data_coils.m b/matlab/IMAS/data_coils.m
index 28fe720a2cdf1e05eabea725d73a4a486232d9ce..e29c3e116a5ff6291824d5e3c6b97e81b0354635 100644
--- a/matlab/IMAS/data_coils.m
+++ b/matlab/IMAS/data_coils.m
@@ -12,7 +12,7 @@ Z = [ 5.4640; 3.2780; 1.0920; -1.0720; -3.2580; -5.4440;...
 dR = [0.7400; 0.7400;0.7400;0.7400;0.7400;0.7400;0.9590;0.5801;0.6963;0.6382;0.8125;1.5590;0.132;0.132];
 dZ = [2.0930; 2.093; 2.093; 2.093; 2.093; 2.093; 0.9841; 0.7146; 0.9538; 0.9538; 0.9538; 1.1075; 0.132;0.132];
 
-N = [554;554;554;554;554;554;248.6;115.2;185.9;169.9;216.8;459.4; 4; 4];
+N = [554;554;554;554;554;554;248.6;115.2;185.9;169.9;216.8;459.4; 4; -4];
 
 N = round(N);
 
diff --git a/matlab/IMAS/gen_filament.m b/matlab/IMAS/gen_filament.m
index 88b402c23383848051d988987f6a49323c7bfcc5..b71e55bb2ff779a69d775054e84efb49d5457944 100644
--- a/matlab/IMAS/gen_filament.m
+++ b/matlab/IMAS/gen_filament.m
@@ -82,7 +82,7 @@ for ii = 1:numel(AC) % loop all the coils given vvstructure
     
     % Try to use a number of filaments that respect the shape of the parallelogram
     ratio = sqrt((AD*AD'))/sqrt((AB*AB'));
-    num1 = ceil(sqrt(num(ii)*ratio));
+    num1 = ceil(sqrt(abs(num(ii))*ratio));
     num2 = ceil(num1/ratio);
     
     pointx = zeros(num1*num2, 1);
@@ -102,7 +102,7 @@ for ii = 1:numel(AC) % loop all the coils given vvstructure
     % but will not necessarily generate a number of windings = number of
     % turns. The following normalization garanties that the total current
     % flowing in the cross section of coil Iw*nw = Ia*nturns respects the input data.
-    Twc(end+1:end+num1*num2,end+1) = 1*sign(num(ii))/(num1*num2)*num(ii);
+    Twc(end+1:end+num1*num2,end+1) = 1*abs(num(ii)/(num1*num2))*sign(num(ii));
 end
 
 % Reshape filaments(windings) into unique vector