replace for..in loops (fixes #6)