made changes to move one time used variables into error catching if statement
Merge pull request #5 from Tanerax/master

Lowered the line count to under 78