Fixed INSIDE the ugly loop this time