Move script main to a separate function
Merge pull request #2 from dbader/refactor-main

Move script main to a separate function