Refactored loops