extract better loops