Fefactored loop