need to figure out global variables and variable scope