Simplification of the code

Instead of 3 if statements containing almost the same code, one switch statement and one small helper method.
Merge pull request #12 from HiddenCloud/master

Simplification of the Extraction code