edited img loop syntax