Use a functional style instead of for loops