A replacement for lots of for loops