Syntax error/eliminating 2 global variables