Refactors script into seperate file and fix #25
Merge pull request #26 from syntonym/bugfix25

Refactors script into seperate file and fix #25