Refactored to loop factors