Improved the loop