match var was defined at wrong scope