Add loop
Merge pull request #1 from rakoo/master

Added switch-in-loop thanks to rakoo.