Split up usage of variable
Add error output and sanity-check