only got past earlier errors with global variables. still errors with scan