made loop #1 more scala-y