This loop appears twice (here and https://github.com/Wikia/app/pull/3800/files#diff-0677cf94deeee06e6ad122d00550f25cR259); it should probably be pulled out.