revised loop