Added globals for JSHint
cleaned up poor scope