Clean up awkward "each" loop