a loop that actually works