switched vars to functions for global scope