have global and local variable problem. arranged function so they are in order and can be called on properly