factorize switch
Merge pull request #149 from lucasmichot/swicth

Factorize switch