fixing a bunch of undefined variables