added globals to resolve undefined variable error