Improved the loop

Some inconsistensies exist