Exit when execution requirements are not met
Rewrite the variable assignment, so script user does not have to edit script
Simplify the code