generate loop