fix undeclared variable error